﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class tim : System.Web.UI.Page
{
    private string Connect = ConfigurationManager.ConnectionStrings["ketnoi"].ConnectionString;
    SqlConnection con;
    SqlDataAdapter ad;
    DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        string timsp = Request.QueryString["timsp"];
        string sql = "select Top 14 * from SAN_PHAM where Tensp like '" + timsp + "%'";

        con = new SqlConnection(Connect);
        con.Open();
        ad = new SqlDataAdapter(sql, con);
        ad.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            GridView1.DataSource = dt;
            GridView1.DataBind();
            if (dt.Rows.Count == 1)
            {
                lblcount.Text = "Tìm được ' " + dt.Rows.Count + " ' kết quả cho '<b>" + timsp + "</b>'";
            }
            else
            {
                lblcount.Text = "Tìm được ' " + dt.Rows.Count + " ' kết quả gần giống với '<b>" + timsp + "</b>'";
            }
        }
        else if (dt.Rows.Count == 0)
        {
            lblcount.Text = "Không tìm thấy '" + timsp+ "'";
        }
        con.Dispose();
        con.Close();
    }    
}
